﻿namespace LargeFilesSample
{
    [Serializable]
    public class ApiResponse<T> : IApiResponse where T : class
    {
        /// <summary>
        /// 无数据时允许被设置为null
        /// </summary>
        public T? Data { get; }

        public string Message { get; }

        public ApiResponse(T? data, string message)
        {
            this.Data = data;
            Message = message;
        }
        public static ApiResponse<T> Success(T data)
        {
            return new ApiResponse<T>(data, "Success");
        }
        public static ApiResponse<T> Fail(T data, string errorMessage)
        {
            return new ApiResponse<T>(data, errorMessage);
        }
    }
}
